<?php
class ControllerPageDetail extends Controller
{
	public function index()
	{
		$this->load->model("core/sitemap");
		
		$siteid = $this->member->getSiteId();
		
		$this->document->sitemapid = $this->request->get['sitemapid'];
		$id = $this->request->get['id'];
		
		$this->document->breadcrumb = $this->model_core_sitemap->getBreadcrumb($this->document->sitemapid, $siteid, -1);
		
		if($this->document->sitemapid != "")
		{
			$sitemap = $this->model_core_sitemap->getItem($this->document->sitemapid, $siteid);
			
			switch($sitemap['moduleid'])
			{
				case "":
					$this->data['module'] = $this->loadModule('addon/'.$this->document->sitemapid);
				break;
				case "module/information":
					$this->data['module'] = $this->loadModule('module/information');
				break;
				case "module/location":
					$this->data['module'] = $this->loadModule('module/location');
				break;
				case "module/banner":
					if($id == "")
					{
						$template = array(
										  'template' => "module/news_list.tpl",
										  'width' => 180,
										  'height' =>180
										  );
						$arr = array("",10,"",$template);
						
						$this->data['module'] = $this->loadModule('module/pagelist','getList',$arr);
					}
					else
					{
						$template = array(
									  'template' => "module/banner_detail.tpl",
									  'width' => 176,
									  'height' =>176
									  );
						$arr = array("",8,$template);
						$this->data['module'] = $this->loadModule('module/pagedetail','getForm',$arr);
					}
				break;
				case "module/news":
					if($id == "")
					{
						$template = array(
										  'template' => "module/news_list.tpl",
										  'width' => 180,
										  'height' =>180
										  );
						$arr = array("",10,"",$template);
						
						$this->data['module'] = $this->loadModule('module/pagelist','getList',$arr);
					}
					else
					{
						$template = array(
									  'template' => "module/news_detail.tpl",
									  'width' => 176,
									  'height' =>176
									  );
						$arr = array("",8,$template);
						$this->data['module'] = $this->loadModule('module/pagedetail','getForm',$arr);
					}
				break;
				case "module/product":
					if($id == "")
					{
						$template = array(
										  'template' => "module/product_list.tpl",
										  'width' => 170,
										  'height' =>170
										  );
						$arr = array($this->document->sitemapid,9,"",$template);
						$this->data['module'] = $this->loadModule('module/productlist','index',$arr);

					}
					else
					{
						$template = array(
									  'template' => "module/product_detail.tpl",
									  'width' => 250,
									  'height' =>250
									  );
						$arr = array($this->document->sitemapid,12,$template);
						$this->data['module'] = $this->loadModule('module/productlist','getFormProduct',$arr);
					}
				break;
				case "module/album":
					if($id == "")
					{
						$template = array(
										  'template' => "module/album_list.tpl",
										  'width' => 150,
					 					  'height' =>114
										  );
						$arr = array($this->document->sitemapid,12,"",$template);
						$this->data['module'] = $this->loadModule('module/productlist','index',$arr);

					}
					else
					{
						$template = array(
									  'template' => "module/album_detail.tpl",
									  'width' => 600,
									  'height' =>600
									  );
						$arr = array($this->document->sitemapid,12,$template);
						$this->data['module'] = $this->loadModule('module/pagedetail','getFormProduct',$arr);
					}
				break;
				case "module/contact":
					$this->data['module'] = $this->loadModule('module/contact');
				break;
				
				case "addon/bds":
					if($id == "" || $id=="search")
					{
						$template = array(
										  'template' => "module/bds_list.tpl",
										  'width' => 150,
					 					  'height' =>114
										  );
						$arr = array($this->document->sitemapid,12,"",$template);
						$this->data['module'] = $this->loadModule('module/bds','getList',$arr);

					}
					else
					{
						$template = array(
										  'template' => "module/bds_detail.tpl",
										  'width' => 200,
					 					  'height' =>200
										  );
						$arr = array($this->document->sitemapid,12,"",$template);
						$this->data['module'] = $this->loadModule('module/bds','getDetail',$arr);
					}
				break;
				
				case "group":
					$this->data['module'] = $this->loadModule('module/'.$this->document->sitemapid);
				break;
			}
		}
		
		$this->loadSiteBar();
		$this->id="content";
		$this->template="page/detail.tpl";
		$this->layout="layout/home";
		$this->render();
	}
	
	private function loadSiteBar()
	{
		//Left sitebar
		/*$this->data['produtcategory'] = $this->loadModule('sitebar/catalogue');
		$this->data['supportonline'] = $this->loadModule('sitebar/supportonline');
		$this->data['exchange'] = $this->loadModule('sitebar/exchange');
		$this->data['weblink'] = $this->loadModule('sitebar/weblink');
		$this->data['hitcounter'] = $this->loadModule('sitebar/hitcounter');*/
		
		//Rigth sitebar
		/*if($this->document->sitebar['login'] != "hide")
			$this->data['login'] = $this->loadModule('sitebar/login');
		$this->data['search'] = $this->loadModule('sitebar/search');
		$this->data['cart'] = $this->loadModule('sitebar/cart');
		$this->data['banner'] = $this->loadModule('sitebar/banner');
		$this->data['question'] = $this->loadModule('sitebar/question');*/
		
		$template = array(
					  'template' => "sitebar/news.tpl",
					  'width' => 100,
					  'height' =>100
					  );
		$arr = array("tintuc",5, $this->document->text['tinmoi'],$template);
		$this->data['tintuc'] = $this->loadModule('sitebar/news','index',$arr);
		
		$template = array(
					  'template' => "sitebar/services.tpl",
					  'width' => 100,
					  'height' =>100
					  );
		$arr = array("dichvu",5,"",$template);
		$this->data['dichvu'] = $this->loadModule('sitebar/news','index',$arr);
		
		$this->data['supportonline'] = $this->loadModule('sitebar/supportonline');
		$this->data['weblink'] = $this->loadModule('sitebar/weblink');
	}
}
?>